<?php
/**
 * 注：此模板为自动生成模板，需要根据实际情况调整修改
 * 此模板对 无主键/单一主键 表的支持较好，联合主键表在下一版本开发
 */
namespace Data;

use Utils\MyException;

class Tree_productor {

    //数组
    private $array;


    public function __construct ($array){

        $this->array = $array;

        self::setDefault();

    }

    public function getArray() {
        return $this->array;
    }

    public function updateWithArray($array) {
        foreach($array as $key=>$value)
        {
            if(array_key_exists($key,$this->array))
            {
                $this->array = array_merge($this->array,array($key=>$value));
            }
        }
    }



    private function setDefault(){

        if(count($this->array)==0){
            self::setPRODUCTOR_ID("null");
            self::setSPECIES_ID("0");
            self::setGROUP_ID("0");
            self::setGG_ID("0");
            self::setGG_CS("");
            self::setPRICE("0");
            self::setPROVINCE("");
            self::setCITY("");
            self::setCOUNTY("");
            self::setDISPLAY_ORDER("0");
            self::setVISIT_COUNT("0");
            self::setDATE("");
            self::setCREATED_ON("");
            self::setCREATED_BY("0");
            self::setUPDATED_ON("");
            self::setUPDATED_BY("0");

        }
    }






    public function setPRODUCTOR_ID($value) {
        $this->array = array_merge ($this->array,array(
            'PRODUCTOR_ID' => $value));
    }
    public function getPRODUCTOR_ID(){

        return $this->array ['PRODUCTOR_ID'];
    }


    public function setSPECIES_ID($value) {
        $this->array = array_merge ($this->array,array(
            'SPECIES_ID' => $value));
    }
    public function getSPECIES_ID(){

        return $this->array ['SPECIES_ID'];
    }


    public function setGROUP_ID($value) {
        $this->array = array_merge ($this->array,array(
            'GROUP_ID' => $value));
    }
    public function getGROUP_ID(){

        return $this->array ['GROUP_ID'];
    }


    public function setGG_ID($value) {
        $this->array = array_merge ($this->array,array(
            'GG_ID' => $value));
    }
    public function getGG_ID(){

        return $this->array ['GG_ID'];
    }


    public function setGG_CS($value) {
        $this->array = array_merge ($this->array,array(
            'GG_CS' => $value));
    }
    public function getGG_CS(){

        return $this->array ['GG_CS'];
    }


    public function setPRICE($value) {
        $this->array = array_merge ($this->array,array(
            'PRICE' => $value));
    }
    public function getPRICE(){

        return $this->array ['PRICE'];
    }


    public function setPROVINCE($value) {
        $this->array = array_merge ($this->array,array(
            'PROVINCE' => $value));
    }
    public function getPROVINCE(){

        return $this->array ['PROVINCE'];
    }


    public function setCITY($value) {
        $this->array = array_merge ($this->array,array(
            'CITY' => $value));
    }
    public function getCITY(){

        return $this->array ['CITY'];
    }


    public function setCOUNTY($value) {
        $this->array = array_merge ($this->array,array(
            'COUNTY' => $value));
    }
    public function getCOUNTY(){

        return $this->array ['COUNTY'];
    }


    public function setDISPLAY_ORDER($value) {
        $this->array = array_merge ($this->array,array(
            'DISPLAY_ORDER' => $value));
    }
    public function getDISPLAY_ORDER(){

        return $this->array ['DISPLAY_ORDER'];
    }


    public function setVISIT_COUNT($value) {
        $this->array = array_merge ($this->array,array(
            'VISIT_COUNT' => $value));
    }
    public function getVISIT_COUNT(){

        return $this->array ['VISIT_COUNT'];
    }


    public function setDATE($value) {
        $this->array = array_merge ($this->array,array(
            'DATE' => $value));
    }
    public function getDATE(){

        return $this->array ['DATE'];
    }


    public function setCREATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_ON' => $value));
    }
    public function getCREATED_ON(){

        return $this->array ['CREATED_ON'];
    }


    public function setCREATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'CREATED_BY' => $value));
    }
    public function getCREATED_BY(){

        return $this->array ['CREATED_BY'];
    }


    public function setUPDATED_ON($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_ON' => $value));
    }
    public function getUPDATED_ON(){

        return $this->array ['UPDATED_ON'];
    }


    public function setUPDATED_BY($value) {
        $this->array = array_merge ($this->array,array(
            'UPDATED_BY' => $value));
    }
    public function getUPDATED_BY(){

        return $this->array ['UPDATED_BY'];
    }


    public function toInsertCSV() {
        $str="";

        // PRODUCTOR_ID
        $str .= self::getPRODUCTOR_ID().",";
        // SPECIES_ID
        $str .= "'". self::getSPECIES_ID()."',";
        // GROUP_ID
        $str .= "'". self::getGROUP_ID()."',";
        // GG_ID
        $str .= "'". self::getGG_ID()."',";
        // GG_CS
        $str .= "'". self::getGG_CS()."',";
        // PRICE
        $str .= "'". self::getPRICE()."',";
        // PROVINCE
        $str .= "'". self::getPROVINCE()."',";
        // CITY
        $str .= "'". self::getCITY()."',";
        // COUNTY
        $str .= "'". self::getCOUNTY()."',";
        // DISPLAY_ORDER
        $str .= "'". self::getDISPLAY_ORDER()."',";
        // VISIT_COUNT
        $str .= "'". self::getVISIT_COUNT()."',";
        // DATE
        $str .= "'". self::getDATE()."',";
        // CREATED_ON
        $str .= "now()" . ",";

        // CREATED_BY
        $str .= "'". self::getCREATED_BY()."',";
        // UPDATED_ON
        $str .= "now()" . ",";

        // UPDATED_BY
        $str .= "'". self::getUPDATED_BY()."'";
        return $str;
    }



    public function toUpdateSet() {
        $str="";

        // SPECIES_ID
        $str.= '`SPECIES_ID` = "' . self::getSPECIES_ID() . '",';

        // GROUP_ID
        $str.= '`GROUP_ID` = "' . self::getGROUP_ID() . '",';

        // GG_ID
        $str.= '`GG_ID` = "' . self::getGG_ID() . '",';

        // GG_CS
        $str.= '`GG_CS` = "' . self::getGG_CS() . '",';

        // PRICE
        $str.= '`PRICE` = "' . self::getPRICE() . '",';

        // PROVINCE
        $str.= '`PROVINCE` = "' . self::getPROVINCE() . '",';

        // CITY
        $str.= '`CITY` = "' . self::getCITY() . '",';

        // COUNTY
        $str.= '`COUNTY` = "' . self::getCOUNTY() . '",';

        // DISPLAY_ORDER
        $str.= '`DISPLAY_ORDER` = "' . self::getDISPLAY_ORDER() . '",';

        // VISIT_COUNT
        $str.= '`VISIT_COUNT` = "' . self::getVISIT_COUNT() . '",';

        // DATE
        $str.= '`DATE` = "' . self::getDATE() . '",';

        // CREATED_ON
        $str.= '`CREATED_ON` = "' . self::getCREATED_ON() . '",';

        // CREATED_BY
        $str.= '`CREATED_BY` = "' . self::getCREATED_BY() . '",';

        // UPDATED_ON
        $str .= "UPDATED_ON = now()," ;

        // UPDATED_BY
        $str.= '`UPDATED_BY` = "' . self::getUPDATED_BY(). '"';
        return $str;
    }



    public function toUpdateWhere(){
        $str = "";
        $str .= "`PRODUCTOR_ID` = '" . self::getPRODUCTOR_ID()."'";
        return $str;
    }

}

